package com.yanqu.backendweb.controller;

import com.alibaba.fastjson.JSON;
import com.yanqu.backendweb.service.impl.RechargeServiceImpl;
import com.yanqu.backendweb.utils.Response;
import com.yanqu.backendweb.utils.Utils;
import com.yanqu.backendweb.vo.RechargeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.SortedMap;

/**
 * @author duli
 * @version 1.0
 * @date 2020/10/27 15:32
 * @Description
 */
@Controller
@RequestMapping("/recharge")
public class RechargeController {
    @Autowired
    private RechargeServiceImpl rechargeService;

    /*
     * 查询玩家充值信息
     * */
    @RequestMapping("/getRole")
    @ResponseBody
    public Response getRole(String requestId, String sign, @RequestBody @Valid RechargeVo vo) {
        SortedMap<String, Object> paramMap = JSON.parseObject(JSON.toJSONString(vo), SortedMap.class);
        paramMap.put("requestId",requestId);
        boolean flag= Utils.checkSign(paramMap,sign);
        if(flag){
            return rechargeService.getRole(vo);
        }else{
            return Response.singError();
        }

    }
}
